namespace ArrayLength {
	// 实现初始化固定长度的数组，初始化元组
	type BuildArray<
		N extends number,
		Ele = unknown,
		Result extends unknown[] = [],
	> = Result["length"] extends N
		? Result
		: BuildArray<N, Ele, [...Result, unknown]>;

	// 加法
	type Add<Num extends number, Num2 extends number> = [
		...BuildArray<Num>,
		...BuildArray<Num2>,
	]["length"];

	// 计算两个数值相加，在TS 类型中是无法计算数字的加减剩除的
	type TestAdd = Add<1, 0>;

	// 减法
	type Subtract<
		num1 extends number,
		num2 extends number,
	> = BuildArray<num1> extends [...BuildArray<num2>, ...infer T]
		? T["length"]
		: 0;

	type TestSubtract = Subtract<10, 9>;

	// 乘法
	type Mutiply<
		T extends number,
		K extends number,
		Temp extends unknown[] = [],
	> = K extends 0
		? Temp["length"]
		: Mutiply<T, Subtract<K, 1>, [...BuildArray<T>, ...Temp]>;

	type TestMutiply = Mutiply<8, 3>;

	// 除法
	type Divide<
		T extends number,
		K extends number,
		Temp extends unknown[] = [],
	> = T extends 0
		? Temp["length"]
		: Divide<Subtract<T, K>, K, [unknown, ...Temp]>;

	type TestDivide = Divide<30, 6>; // 希望得到是 6
}
